home *** CD-ROM | disk | FTP | other *** search
- c
- c Another very simple test program for vopl.
- c
- c This one also draws a graph of y = sin(x) 0 <= x <= 2*pi
- c but shows some of the axis and range setting stuff
- c
- program test1
- #ifdef SGI_GL
- #include "fgl.h"
- #include "fdevice.h"
- #else
- #include "fvogl.h"
- #include "fvodevice.h"
- #endif
-
- parameter (pi = 3.14159265358979)
- parameter (n = 300)
-
- real x(n), y(n)
-
- integer *2 val, left, right, bottom, top
- c
- c Generate the points
- c
- t = 0.0
- dt = 2 * pi / n
-
- do 10 i = 1, n
- x(i) = t
- y(i) = sin(t)
- t = t + dt
- 10 continue
-
- c
- c Set the X-scaling to be absolute 0 - 10 (ie no auto-scaling)
- c
- call range(0.0, 10.0, 'x')
- c
- c Autoscale the Y-axis
- c
- call adjustscale(y, n, 'y')
- c
- c Anyone for some axis titles?
- c
- call axistitle('This one''s for you', 'x')
- call axistitle('This one''s for me', 'y')
- c
- c As we are now about to do some graphics we initialise VOGLE
- c and clear to BLACK
- c
- call hfont('futura.l', 8)
- call winope('VOPL', 4)
- call qdevic(KEYBD)
- call color(0)
- call clear
- c
- c Now set the color to GREEN
- c
- call color(2)
-
- c
- c Draw the default set of axes (in GREEN)
- c
- call drawaxes2
- c
- c Set color to RED
- c
- call color(1)
- c
- c Draw the Graph
- c
- call plot2(x, y, n)
- c
- c Wait around a bit
- c
- idum = qread(val)
- c
- c Now draw a little one in the top right hand corner
- c by reseting the VOGL viewport.
- c
- call getvie(left, right, bottom, top)
- c
- c Now assign them to integer *4 variables (thanks SGI!)
- c
- minx = left
- maxx = right
- miny = bottom
- maxy = top
- call viewpo((minx + maxx) / 2, maxx, (maxy + miny) / 2, maxy)
- c
- c Draw it again, but do the plot first (in BLUE) then the axes
- c (in YELLOW)
- c
- call color(4)
- call plot2(x, y, n)
- call color(3)
- call drawaxes2
- c
- c Hang around again
- c
- idum = qread(val)
- c
- c Clear it all away
- c
- call viewpo(minx, maxx, miny, maxy)
- call color(0)
- call clear
- c
- c Reset the viewport to be a "long skinny one"
- c
- c
- call viewpo(minx, maxx,
- + miny + (maxy + miny) / 3, maxy - (maxy + miny)/ 3)
-
- c Autoscale the X-axis again by first setting a ridicuous scale with
- c range that adjustscale will change.
- c
- call range(1000.0, -1000.0, 'x')
- call adjustscale(x, n, 'x')
- c
- c Change the X-axis title
- c
- call axistitle('Blark Bonk Bloot', 'x')
- c
- c And draw it all again...
- c
- call color(5)
- call drawaxes2
- call color(6)
- call plot2(x, y, n)
- c
- c Hang around again
- c
- idum = qread(val)
- c
- c Bugger off...
- c
-
- call gexit
- end
-